/*
 * Copyright 2007 National Bioinformatics Network
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package dgbgui.gui.dialogs;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;

import dgbgui.modeldocument.Query;
import dgbgui.tools.DialogedTool;

@SuppressWarnings("serial")
public class RenameDialog extends DGBGUIDialog {

    public RenameDialog(DialogedTool tool, Query query) {
        super(tool,"Rename");
        setLayout(new BoxLayout(getContentPane(),BoxLayout.Y_AXIS));

        JPanel qlPanel = new JPanel();
        Border panelBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        qlPanel.setBorder(BorderFactory.createTitledBorder(panelBorder,"Label"));
        qlPanel.setLayout(new BoxLayout(qlPanel, BoxLayout.X_AXIS));
        JLabel nameLabel = new JLabel("New label: ");
        m_newLabelField = new JTextField(query.getLabel());
        qlPanel.add(nameLabel);
        qlPanel.add(m_newLabelField);

        add(qlPanel);

        // Add the OK and Cancel buttons
        JPanel buttonsPanel = new JPanel();
        buttonsPanel.setLayout(new BoxLayout(buttonsPanel,BoxLayout.X_AXIS));
        m_okButton = new JButton("OK");
        m_cancelButton = new JButton("Cancel");
        buttonsPanel.add(m_okButton);
        buttonsPanel.add(m_cancelButton);

        m_okButton.addActionListener(tool);
        m_cancelButton.addActionListener(tool);

        add(buttonsPanel);

    }
    
    public String getName() {
        return m_newLabelField.getText();
    }
        
    private JTextField m_newLabelField;

}
